home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / all macintosh / quicktime for java / musicmixer / src / mixer / mc / mixermusictrack.java < prev    next >
Encoding:
Java Source  |  2000-06-23  |  2.1 KB  |  80 lines

  1. /*
  2.  * QuickTime for Java SDK Sample Code
  3.  
  4.    Usage subject to restrictions in SDK License Agreement
  5.  * Copyright: © 1996-1999 Apple Computer, Inc.
  6.  
  7.  */
  8. package mixer.mc;
  9.  
  10. import mixer.display.MusicPartDisplay;
  11.  
  12. import quicktime.*;
  13. import quicktime.app.audio.*;
  14. import quicktime.std.music.*;
  15. import quicktime.std.movies.*;
  16. import quicktime.std.movies.media.*;
  17.  
  18. import javax.swing.*;
  19. import java.awt.*;
  20.  
  21. /** This class is an implementation of the MixerComponents interface to deal
  22.  *  with Music tracks.
  23.  */
  24. public class MixerMusicTrack implements MixerComponents {        
  25.     private MusicMediaControl master;
  26.     private MixerMusicPart chans[] = null;
  27.     private Movie mov;
  28.     
  29.     /** The constructor just needs to know which MusicMedia object it is related to. */
  30.     public MixerMusicTrack (Movie mov, MusicMedia m) throws QTException {
  31.         master = new MusicMediaControl(m);
  32.         this.mov = mov;
  33.     }
  34.  
  35.     /** Returns the AudioSpec object capable of controlling this MixerMusicTrack.
  36.      *  @return the AudioSpec control object
  37.      */
  38.     public AudioSpec getMaster () {
  39.         return master;
  40.     }
  41.  
  42.     /** This method creates the JComponent which contains the controls for modifying
  43.      *  the channels of this object.
  44.      *  @return the JComponent with the controls
  45.      */
  46.     public JComponent makeEditComponent () throws QTException {
  47.         return new MusicPartDisplay (mov, getChannels());
  48.     }
  49.     
  50.     /** This method returns an array of the MixerComponents which are the children
  51.      *  of this object.
  52.      *  @return the children MixerComponents
  53.      */
  54.     public MixerComponents[] getChannels () {
  55.         if (chans == null) {
  56.             try {
  57.                 int numComp = master.getPartCount();
  58.                 chans = new MixerMusicPart[numComp];
  59.                 
  60.                 for (int i = 0; i < numComp; i++)
  61.                     chans[i] = new MixerMusicPart(master.getPart(i+1));
  62.             }
  63.             catch (QTException e) {
  64.                 e.printStackTrace();
  65.             }
  66.         }        
  67.         return chans;
  68.     }
  69.  
  70.     /** This object is defined as editable if there are some child channels.
  71.      *  @return the editable status
  72.      */
  73.     public boolean isEditable() { 
  74.         try {
  75.             return master.getPartCount() > 0;
  76.         } catch (QTException e) {
  77.             return false;
  78.         }
  79.     }
  80. }